Skip to content

feat(user.js): consolidate CP userscripts and deprecate legacy CP scripts#283

Merged
netravnen merged 9 commits intomasterfrom
feat/cp-unified-userscript-modular-runtime-isolation
Feb 23, 2026
Merged

feat(user.js): consolidate CP userscripts and deprecate legacy CP scripts#283
netravnen merged 9 commits intomasterfrom
feat/cp-unified-userscript-modular-runtime-isolation

Conversation

@netravnen
Copy link
Contributor

@netravnen netravnen commented Feb 17, 2026

Summary

This PR consolidates all peeringdb-cp-* functionality into a single modular userscript with strict route isolation and hard no-op guards outside intended contexts.

It also migrates legacy CP scripts to deprecation stubs (console notice only) with synchronized bugfix version bumps in both .user.js and .meta.js, and updates user.js/README.md with migration guidance.

What changed

  • Added consolidated CP script pair:
    • user.js/peeringdb-cp-consolidated-tools.user.js
    • user.js/peeringdb-cp-consolidated-tools.meta.js
  • Consolidated architecture:
    • central route context resolver + dispatcher
    • per-module match(ctx), preconditions(), run()
    • shared utilities for safe querying, toolbar action insertion, org lookup, and idempotent action registration
  • Preserved network action behavior:
    • immediate Save+Continue for network update/reset flows
    • robust name assignment fallback handling
  • Converted legacy CP scripts to deprecation stubs (behavior removed, console notice added):
    • peeringdb-cp-add-facility-address-search-to-google-maps.*
    • peeringdb-cp-admin-console-set-link-target-blank-for-entity-website.*
    • peeringdb-cp-control-panel-hightlight-dummy-organization-child-object.*
    • peeringdb-cp-frontpage-link-on-admin-console.*
    • peeringdb-cp-reset-all-network-information.*
    • peeringdb-cp-search-user-e-mail-addresses-from-username.*
    • peeringdb-cp-set-network-name-equal-to-organisation-name.*
  • Updated docs:
    • user.js/README.md migration and deprecation notes

Metadata + scope decisions

  • Host scope restricted to www.peeringdb.com
  • Consolidated script uses @match
  • Consolidated scope:
    • https://www.peeringdb.com/cp/peeringdb_server/*/*/change/*
  • Legacy .meta.js and .user.js headers kept version-synchronized

Route-by-route verification checklist

  • Facility change page (/cp/peeringdb_server/facility/<id>/change/)
    • “Google Maps” action appears
    • Dummy-org highlight appears only when org id is dummy org
    • No duplicate toolbar items after reload
  • Network change page (/cp/peeringdb_server/network/<id>/change/)
    • “Frontend” / org links appear as expected
    • “Update Name” updates name from org and saves immediately
    • “Reset Information” resets fields and saves immediately
    • Deleted network suffix behavior preserved (#<id> where expected)
    • No duplicate toolbar items after reload
  • Organization/Carrier/IX/Campus change pages
    • Frontend/admin links behave as expected
    • Website link target behavior opens in expected target
  • User change page (/cp/peeringdb_server/user/<id>/change/)
    • “Search Username” link resolves to account email search correctly
  • Non-target CP pages
    • No module side effects
    • No console/runtime errors from consolidated script
  • Legacy script migration
    • Each legacy CP script logs deprecation notice only
    • No legacy behavior executes
    • Legacy .meta.js / .user.js versions match

Validation notes

  • Static checks in workspace reported no syntax/problems.
  • Manual browser verification pending (checklist above).

Follow-up

After checklist completion, this PR is ready for review/merge.

@netravnen
Copy link
Contributor Author

Toolbar regression fix pushed in d524742.

What changed:

  • addToolbarAction now inserts isolated sibling
      wrappers (legacy-compatible pattern) instead of injecting
    • directly into the built-in #grp-content-title > ul list.
    • This avoids interfering with the native CP toolbar/history layout implementation.
    • Consolidated script version bumped to 1.0.1.20260217 in both .user.js and .meta.js.

    Please re-verify on CP pages that toolbar/history layout is intact and actions render correctly without duplicates.

@netravnen
Copy link
Contributor Author

Follow-up toolbar clickability fix pushed in f4f1f77.

Issue:

  • Only Google Maps and History were clickable because overlapping custom toolbar
      layers were intercepting pointer events.

    Fix:

    • Set pointer-events: none on each injected wrapper
        .
      • Set pointer-events: auto on each injected action link.
      • Bumped consolidated script version to 1.0.2.20260217 in both .user.js and .meta.js.

      Please re-test facility/network pages and confirm all custom action links are clickable.

@netravnen
Copy link
Contributor Author

Added RDAP ASN fallback for reset flow in commit ce75b70.

What it does:

  • Introduces an isolated RDAP client module (rdapAutnumClient) outside feature-module logic.
  • Uses IANA ASN bootstrap registry (RFC 9224) to find authoritative RDAP base URL.
  • Queries /autnum/{asn} and resolves organization name from RDAP entities/jCard data with registrant-first scoring.
  • In reset action: if both resolved network name and original network name are empty, performs RDAP lookup using integer ASN (#id_asn) and uses that organization name (plus deleted suffix when applicable) before save.

Version bump:

  • Consolidated script/meta updated to 1.0.3.20260217.

@netravnen
Copy link
Contributor Author

Adjusted reset fallback order in commit 2aa4794.

What it does:

  • Removes dependency on original network name in the reset flow.
  • Uses resolved network name from org API as the primary source.
  • If resolved network name is empty, falls back directly to isolated RDAP ASN lookup (rdapAutnumClient).
  • Keeps deleted-network suffix handling unchanged when a name is resolved.

Version bump:

  • Consolidated script/meta updated to 1.0.4.20260217.

@netravnen
Copy link
Contributor Author

Hardened first-run reset save behavior in commit a0d923f.

What it does:

  • Keeps reset name resolution order: org API first, RDAP ASN second.
  • Adds a final deterministic guard before save: if name is still empty, set it to AS<asn> (or AS<networkId> as fallback) with deleted suffix handling.
  • Prevents required-field validation from blocking clickSaveAndContinue on first run.

Version bump:

  • Consolidated script/meta updated to 1.0.5.20260218.

@netravnen
Copy link
Contributor Author

Update: pushed an additional hardening fix for the alternating Reset Information behavior.

What changed

  • Version bump: 1.0.7.20260218
  • Avoid clearing #id_name in the bulk reset pass
  • Added direct #id_name setter (value + defaultValue + input/change events)
  • Seed deterministic fallback name immediately after reset (AS<asn> / AS<networkId> + deleted suffix)
  • Keep org/RDAP resolution, with a final pre-submit direct guard on #id_name

Commit

  • 95bd461fix(user.js): harden reset name assignment against alternating empty submit

Early results look good; continuing route-by-route verification.

@netravnen
Copy link
Contributor Author

Update: pushed inline deletion-guard changes for Network CP actions.

What changed

  • Version bump: 1.0.9.20260223
  • Added status-aware inline handling so deletion marking only applies when the row status is already deleted
  • Applied to these inline sets:
    • poc_set (network contact)
    • netfac_set (network facilities)
    • netixlan_set (network ix lans)
  • Wired into both actions on /cp/peeringdb_server/network/*/change/:
    • Reset Information
    • Update Name

Behavior guarantee

  • If inline row status is deleted → mark for deletion (right-column cross)
  • If inline row status is not deleted → do not mark for deletion

Commit

  • 3621e7dfix(user.js): only auto-delete network inlines with deleted status

@netravnen netravnen merged commit 3621e7d into master Feb 23, 2026
@netravnen netravnen deleted the feat/cp-unified-userscript-modular-runtime-isolation branch February 23, 2026 20:37
@netravnen
Copy link
Contributor Author

Update: pushed a tiny UX-only naming standardization pass (Org terminology).

What changed

  • Version bump: 1.0.15.20260223
  • Standardized button labels to compact Org naming for consistency:
    • Organization (front-end)Org (front-end)
    • OrganizationOrg
    • Copy organisation URLCopy Org URL
    • Copy success text updated to Copied Org URL

Commit

  • 398845cchore(user.js): standardize toolbar labels to Org naming

Note

  • Remote branch feat/cp-unified-userscript-modular-runtime-isolation had previously been deleted and is now restored/pushed again.

@netravnen netravnen added userscript Tampermonkey/Greasemonkey userscript changes bug labels Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug copilot enhancement llm-built PDB userscript Tampermonkey/Greasemonkey userscript changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant